package com.mchsdk.paysdk.activity;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mchsdk.paysdk.bean.PersonalCenterModel;
import com.mchsdk.paysdk.bean.VerifyCode;
import com.mchsdk.paysdk.common.Constant;
import com.mchsdk.paysdk.http.process.UserBindPhoneProcess;
import com.mchsdk.paysdk.http.process.UserUnBindPhoneProcess;
import com.mchsdk.paysdk.http.process.VerificationCodeProcess;
import com.mchsdk.paysdk.observer.SecondsWatcher;
import com.mchsdk.paysdk.utils.MCHInflaterUtils;
import com.mchsdk.paysdk.utils.MCLog;
import com.mchsdk.paysdk.utils.ToastUtil;
import com.mchsdk.paysdk.view.util.CheckImage;
import com.mchsdk.paysdk.view.util.TimeFactory;

public class MCBindPhoneActivity extends MCBaseActivity {

    private static final String TAG = "MCBindPhoneActivity";
    CheckImage checkImage;
    Activity context;
    String checkNumber;// 验证码
    //上面三个数字
    TextView step1, step_verifyidentity, step_securityphone;
    //上面三个步骤
    TextView step1_, step_verifyidentity_, step_securityphone_;
    //步骤间的横线
    View lineFirst, lineSecond;
    //绑定手机第一个界面
    RelativeLayout bindphone_body_setup1;
    //绑定手机第二个界面
    LinearLayout bindphone_body_setup2;
    //绑定手机成功界面
    LinearLayout bindphone_body_setsuccess;
    //解绑手机按钮和输入手机验证码的输入框
    LinearLayout mch_ll_unbindphone;
    //step1------------------------------------------
    //密码输入框
    EditText edt_bindphone;
    //确定定按钮
    Button btn_bindphone1;
    //step2------------------------------------------
    //手机号码输入框
    EditText step2_edt_phone;
    //验证码输入框
    EditText step2_edt_checknum;
    //验证码按钮
    Button step2_btn_checknum;
    //上一步
    Button step2_btn_back;
    //下一步
    Button step2_btn_next;
    //step3----------------------------------------
    //已绑定手机号
    TextView txt_bindphone_tip;
    //已绑定手机号解除按钮
    TextView txt_unbindphone_tip;
    //已绑定手机号输入框
    EditText edt_unbindphone;
    //验证码按钮
    Button btn_msg_mm;
    //已绑定手机号确定按钮
    Button btn_submit_unbindstep1;

    LinearLayout ll_unbindphone;
    TextView text_title;


    String edit_bindphoneStr;

    Button msg_mm;

    private int step;
    private int isUnBind = 0;
    //	TextView text_title_add;
//	RelativeLayout relativeLayout11;
    TextView text_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = this;
        setContentView(getLayout("activity_mch_personal_info_bindphone2"));
        initView();
        showInit();
    }

    private void initView() {
        MCLog.e(TAG, "fun#initView");
        TextView txtTitle = (TextView) findViewById(MCHInflaterUtils
                .getControl(this, "tv_mch_header_title"));
        txtTitle.setText("安全中心");
        txtTitle.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL);
        ImageView ivBack = (ImageView) findViewById(MCHInflaterUtils
                .getControl(this, "iv_mch_header_back"));
        ivBack.setVisibility(View.VISIBLE);
        ivBack.setOnClickListener(backClick);
        ImageView ivClose = (ImageView) findViewById(MCHInflaterUtils
                .getControl(this, "iv_mch_header_close"));
        ivClose.setVisibility(View.GONE);
        ivClose.setOnClickListener(backClick);

        //最上面步骤显示
        step1 = (TextView) findViewById(getId("step1"));
        step_verifyidentity = (TextView) findViewById(getId("step_verifyidentity"));
        step_securityphone = (TextView) findViewById(getId("step_securityphone"));
        step1_ = (TextView) findViewById(getId("step1_"));
        step_verifyidentity_ = (TextView) findViewById(getId("step_verifyidentity_"));
        step_securityphone_ = (TextView) findViewById(getId("step_securityphone_"));
        lineFirst = (View) findViewById(getId("line_bindphone_1"));
        lineSecond = (View) findViewById(getId("line_bindphone_2"));

        //绑定手机第一个界面
        bindphone_body_setup1 = (RelativeLayout) findViewById(getId("bindphone_body_setup1"));
        //绑定手机第二个界面
        bindphone_body_setup2 = (LinearLayout) findViewById(getId("bindphone_body_setup2"));
        //绑定手机成功界面
        bindphone_body_setsuccess = (LinearLayout) findViewById(getId("bindphone_body_setsuccess"));
        //解除绑定界面
        mch_ll_unbindphone = (LinearLayout) findViewById(getId("mch_ll_unbindphone"));
        //step1------------------------------------------
        //密码输入框

        edt_bindphone = (EditText) findViewById(getId("edt_bindphone"));
        //确定定按钮
        btn_bindphone1 = (Button) findViewById(getId("btn_bindphone1"));
        btn_bindphone1.setOnClickListener(clickListener);
        //step2------------------------------------------
        //手机号码输入框
        step2_edt_phone = (EditText) findViewById(getId("step2_edt_phone"));
        //验证码输入框
        step2_edt_checknum = (EditText) findViewById(getId("step2_edt_checknum"));
        //验证码按钮
        step2_btn_checknum = (Button) findViewById(getId("step2_btn_checknum"));
        step2_btn_checknum.setOnClickListener(clickListener);
        //上一步
        step2_btn_back = (Button) findViewById(getId("step2_btn_back"));
        step2_btn_back.setOnClickListener(clickListener);
        //下一步

        step2_btn_next = (Button) findViewById(getId("step2_btn_next"));
        step2_btn_next.setOnClickListener(clickListener);
        //step3----------------------------------------
        ll_unbindphone = (LinearLayout) findViewById(getId("ll_unbindphone"));

        txt_bindphone_tip = (TextView) findViewById(getId("txt_bindphone_tip"));

        txt_unbindphone_tip = (TextView) findViewById(getId("txt_unbindphone_tip"));
        txt_unbindphone_tip.setOnClickListener(clickListener);
        step_verifyidentity = (TextView) findViewById(getId("step_verifyidentity"));

        step_securityphone = (TextView) findViewById(getId("step_securityphone"));
        step_securityphone.setBackgroundResource(getDrawable("mch_step3_80x80_grey"));
        step_verifyidentity_ = (TextView) findViewById(getId("step_verifyidentity_"));
        step_verifyidentity_.setTextColor(Color.parseColor("#a0a0a0"));
        step_securityphone_ = (TextView) findViewById(getId("step_securityphone_"));
        step_securityphone_.setTextColor(Color.parseColor("#a0a0a0"));
        text_title = (TextView) findViewById(getId("text_title"));

        edt_unbindphone = (EditText) findViewById(getId("edt_unbindphone"));
        msg_mm = (Button) findViewById(getId("btn_msg_mm"));
        msg_mm.setOnClickListener(bindphonelinstener);
        btn_msg_mm = (Button) findViewById(getId("btn_msg_mm"));
        btn_msg_mm.setOnClickListener(bindphonelinstener);
        btn_submit_unbindstep1 = (Button) findViewById(getId("btn_submit_unbindstep1"));
        btn_submit_unbindstep1.setOnClickListener(clickListener);
//		text_title_add = (TextView) findViewById(getId("text_title_add"));
//		relativeLayout11 = (RelativeLayout) findViewById(getId("relativeLayout11"));
        text_back = (TextView) findViewById(getId("text_back"));
        text_back.setOnClickListener(bindphonelinstener);

    }

    OnClickListener clickListener = new OnClickListener() {
        @Override
        public void onClick(View view) {
            /** 解除绑定*/
            if (view.getId() == btn_submit_unbindstep1.getId()) {
                if (isUnBind == 1) {
                    unbind();
                } else {
                    MCBindPhoneActivity.this.finish();
                }
                return;
            }
            /** 控制解绑显示隐藏*/
            if (view.getId() == txt_unbindphone_tip.getId() || view.getId() == txt_bindphone_tip.getId()) {
                if (isUnBind == 1) {
                    title1();
                    ll_unbindphone.setVisibility(View.GONE);
                    isUnBind = 0;
                } else if (isUnBind == 0) {
                    title2();
                    ll_unbindphone.setVisibility(View.VISIBLE);
                    isUnBind = 1;
                }
                return;
            }
            /** 绑定手机验证密码*/
            if (view.getId() == btn_bindphone1.getId()) {
                bindstep1();
                return;
            }
            /** 绑定手机发验证码*/
            if (view.getId() == step2_btn_checknum.getId()) {
                bindstep2num();
                return;
            }
            /** 绑定手机上一步*/
            if (view.getId() == step2_btn_back.getId()) {
                bodystep1();
                return;
            }
            /** 绑定手机下一步*/
            if (view.getId() == step2_btn_next.getId()) {
                bindstep2();
                return;
            }
        }
    };

    /**
     * 绑定手机发送验证码
     */
    private void bindstep2num() {
        TimeFactory.creator(2).getTimeChange()
                .addWatcher(secondsWatcher);
        TimeFactory.creator(3).getTimeChange()
                .removeWatcher(unBindsecondsWatcher);
        step2_btn_checknum.setEnabled(true);
        step2_btn_checknum
                .setBackgroundResource(getDrawable("mc_login_reg_phone_num"));
        String phone = step2_edt_phone.getText().toString().trim();
        if (TextUtils.isEmpty(phone)) {
            ToastUtil.show(context, "请先输入手机号码");
            return;
        }
        String valCode = Constant.REGULAR_PHONENUMBER;
        if (!phone.matches(valCode)) {
            ToastUtil.show(context, "请输入正确的手机号码");
            return;
        }
        step2_btn_checknum.setBackgroundResource(getDrawable("mc_login_reg_phone_num_disable"));
        step2_btn_checknum.setEnabled(false);
        VerificationCodeProcess verifyCodeProcess = new VerificationCodeProcess();
        verifyCodeProcess.setPhone(phone);
        // verifyCodeProcess.get(myHandler);
        verifyCodeProcess.post(myHandler);
    }


    /**
     * 绑定手机第一步
     */
    private void bindstep1() {
        String password = edt_bindphone.getText().toString().trim();
        if (TextUtils.isEmpty(password)) {
            ToastUtil.show(context, "请先输入登录密码");
            return;
        }
        String realpassword = PersonalCenterModel.getInstance().channelAndGame
                .getPassword();
        if (!password.equals(realpassword)) {
            ToastUtil.show(context, "登录密码输入不正确");
            return;
        }
        bodystep2();
    }

    /**
     * 绑定手机
     */
    private void bindstep2() {
        String phone = step2_edt_phone.getText().toString().trim();
        String code = step2_edt_checknum.getText().toString().trim();
        if (TextUtils.isEmpty(phone)) {
            ToastUtil.show(context, "请输入手机号");
            return;
        }
        String valCode = Constant.REGULAR_PHONENUMBER;
        if (!phone.matches(valCode)) {
            ToastUtil.show(context, "请输入正确的手机号码");
            return;
        }
        if (TextUtils.isEmpty(code)) {
            ToastUtil.show(context, "请输入验证码");
            return;
        }
        try {
            UserBindPhoneProcess process = new UserBindPhoneProcess();
            process.setPhone(phone);
            process.setCode("phone");
            process.setSmcode(code);
            process.post(myHandler);
        } catch (Exception e) {
            ToastUtil.show(context, "程序异常");
            e.printStackTrace();
        }
        return;
    }

    OnClickListener backClick = new OnClickListener() {

        @Override
        public void onClick(View v) {
            /**返回监听*/
            if (v.getId() == getId("iv_mch_header_back")) {
                MCBindPhoneActivity.this.finish();
                return;
            }
        }
    };

    private void showInit() {
        step = 1;
        bodystep1();
        String phone = PersonalCenterModel.getInstance().getPhone();

        /**
         * 没有绑定手机
         */
        if (TextUtils.isEmpty(phone)) {
            bodystep1();
        }
        /**
         * 已经绑定手机btn_bindphone
         */
        if (!TextUtils.isEmpty(phone) && phone.length() >= 11) {
            bodystepunbind1();
            StringBuilder tip = new StringBuilder();
            tip.append("已绑定手机号 | ").append(phone.substring(0, 4)).append("****")
                    .append(phone.substring(7));
            txt_bindphone_tip.setText(tip);
            txt_bindphone_tip.setOnClickListener(clickListener);


            String strBindPhone = "解除绑定".toString().trim();
            txt_unbindphone_tip.setText(strBindPhone);
            txt_unbindphone_tip.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
            return;
        }
    }

    OnClickListener bindphonelinstener = new OnClickListener() {

        @Override
        public void onClick(View v) {
            /**
             * 返回
             */
            if (v.getId() == getId("text_back")) {
                MCBindPhoneActivity.this.finish();
                return;
            }

            /** 绑定手机读秒按钮 */
            if (v.getId() == getId("msg_mm")) {
                TimeFactory.creator(2).getTimeChange()
                        .addWatcher(secondsWatcher);
                TimeFactory.creator(3).getTimeChange()
                        .removeWatcher(unBindsecondsWatcher);
                btn_msg_mm.setEnabled(true);
                btn_msg_mm
                        .setBackgroundResource(getDrawable("mc_login_reg_phone_num"));
                String phone = edt_bindphone.getText().toString().trim();
                if (TextUtils.isEmpty(phone)) {
                    ToastUtil.show(context, "请先输入手机号码");
                    return;
                }
                String valCode = Constant.REGULAR_PHONENUMBER;
                if (!phone.matches(valCode)) {
                    ToastUtil.show(context, "请输入正确的手机号码");
                    return;
                }
                msg_mm.setBackgroundResource(getDrawable("mc_login_reg_phone_num_disable"));
                msg_mm.setEnabled(false);
                VerificationCodeProcess verifyCodeProcess = new VerificationCodeProcess();
                verifyCodeProcess.setPhone(phone);
                // verifyCodeProcess.get(myHandler);
                verifyCodeProcess.post(myHandler);
                return;
            }
            /** 解绑手机读秒按钮 */
            if (v.getId() == getId("btn_msg_mm")) {
                TimeFactory.creator(3).getTimeChange()
                        .addWatcher(unBindsecondsWatcher);
                TimeFactory.creator(2).getTimeChange()
                        .removeWatcher(secondsWatcher);
                msg_mm.setEnabled(true);
                msg_mm.setBackgroundResource(getDrawable("mc_login_reg_phone_num"));

                String phone = PersonalCenterModel.getInstance().getPhone();
                if (TextUtils.isEmpty(phone)) {
                    ToastUtil.show(context, "该账号没有绑定手机号码");
                    return;
                }
                String valCode = Constant.REGULAR_PHONENUMBER;
                if (!phone.matches(valCode)) {
                    ToastUtil.show(context, "该账号绑定的手机号码无法被识别");
                    return;
                }
                btn_msg_mm
                        .setBackgroundResource(getDrawable("mc_login_reg_phone_num_disable"));
                btn_msg_mm.setEnabled(false);
                VerificationCodeProcess verifyCodeProcess = new VerificationCodeProcess();
                verifyCodeProcess.setPhone(phone);
                // verifyCodeProcess.get(myHandler);
                verifyCodeProcess.post(UnBindHandler);
                return;
            }
        }
    };

    Handler secondsHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (null != step2_btn_checknum) {
                String seconds = (String) msg.obj;
                // MCLog.e(TAG, "seconds= " + seconds);
                if ("0".equals(seconds)) {
                    step2_btn_checknum.setText("获取验证码");
                    step2_btn_checknum.setEnabled(true);
                    step2_btn_checknum.setBackgroundResource(getDrawable("mc_login_reg_phone_num"));
                } else {
                    step2_btn_checknum.setText((String) msg.obj);
                    step2_btn_checknum.setBackgroundResource(getDrawable("mc_login_reg_phone_num_disable"));
                    step2_btn_checknum.setEnabled(false);
                }
            }
        }
    };
    Handler UnBindSecondsHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (null != btn_msg_mm) {
                String seconds = (String) msg.obj;
                // MCLog.e(TAG, "seconds= " + seconds);
                if ("0".equals(seconds)) {
                    btn_msg_mm.setText("获取验证码");
                    btn_msg_mm.setEnabled(true);
                    btn_msg_mm
                            .setBackgroundResource(getDrawable("mc_login_reg_phone_num"));
                } else {
                    btn_msg_mm.setText((String) msg.obj);
                    btn_msg_mm
                            .setBackgroundResource(getDrawable("mc_login_reg_phone_num_disable"));
                    btn_msg_mm.setEnabled(false);
                }
            }
        }
    };

    @Override
    protected void onResume() {
        super.onResume();
        // TimeFactory.creator(2).getTimeChange().addWatcher(secondsWatcher);
        TimeFactory.creator(3).getTimeChange().addWatcher(unBindsecondsWatcher);
    }

    ;

    SecondsWatcher secondsWatcher = new SecondsWatcher() {

        @Override
        public void updateSeconds(String seconds) {
            Message msg = new Message();
            msg.what = 0;
            msg.obj = seconds;
            secondsHandler.sendMessage(msg);
        }
    };
    SecondsWatcher unBindsecondsWatcher = new SecondsWatcher() {

        @Override
        public void updateSeconds(String seconds) {
            Message msg = new Message();
            msg.what = 0;
            msg.obj = seconds;
            UnBindSecondsHandler.sendMessage(msg);
        }
    };

    @Override
    protected void onPause() {
        super.onPause();
        TimeFactory.creator(2).getTimeChange().removeWatcher(secondsWatcher);
        TimeFactory.creator(3).getTimeChange()
                .removeWatcher(unBindsecondsWatcher);
    }

    ;

    public Handler myHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case Constant.VERIFYCODE_REQUEST_SUCCESS:// 请求获得手机验证码成功
                    step2_btn_checknum.setBackgroundResource(getDrawable("mc_login_reg_phone_num_disable"));
                    step2_btn_checknum.setEnabled(false);
                    VerifyCode code = (VerifyCode) msg.obj;
                    showCode(code);
                    break;
                case Constant.VERIFYCODE_REQUEST_FAIL:// 请求获得手机验证码失败
                    String res = (String) msg.obj;
                    ToastUtil.show(context, res);
                    step2_btn_checknum.setText("获取验证码");
                    step2_btn_checknum.setEnabled(true);
                    step2_btn_checknum.setBackgroundResource(getDrawable("mc_login_reg_phone_num"));
                    break;
                case Constant.USER_BIND_PHONE_SUCCESS:// 绑定手机成功
                    ToastUtil.show(context, "绑定成功");
                    TimeFactory.creator(2).calcel();
                    shouBindSuccess();
                    break;
                case Constant.USER_BIND_PHONE_FAIL:// 绑定手机失败
                    String message = (String) msg.obj;
                    if (!TextUtils.isEmpty(message)) {
                        ToastUtil.show(MCBindPhoneActivity.this, message);
                    }

                    break;
                default:
                    break;
            }
        }
    };
    public Handler UnBindHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case Constant.VERIFYCODE_REQUEST_SUCCESS:// 请求获得手机验证码成功
                    btn_msg_mm
                            .setBackgroundResource(getDrawable("mc_login_reg_phone_num_disable"));
                    btn_msg_mm.setEnabled(false);
                    VerifyCode code = (VerifyCode) msg.obj;
                    showUnBindCode(code);
                    break;
                case Constant.VERIFYCODE_REQUEST_FAIL:// 请求获得手机验证码失败
                    String res = (String) msg.obj;
                    ToastUtil.show(context, res);
                    btn_msg_mm.setText("获取验证码");
                    btn_msg_mm.setEnabled(true);
                    btn_msg_mm
                            .setBackgroundResource(getDrawable("mc_login_reg_phone_num"));
                    break;
                case Constant.USER_BIND_PHONE_SUCCESS:// 解绑手机成功
                    ToastUtil.show(context, "解除手机绑定成功");
                    TimeFactory.creator(3).calcel();
                    bodystep1();
                    break;
                case Constant.USER_BIND_PHONE_FAIL:// 解绑手机失败
                    String message = msg.obj.toString();
                    if (!TextUtils.isEmpty(message)) {
                        ToastUtil.show(context, message);
                    }
                    break;
                default:
                    break;
            }
        }
    };

    protected void shouBindSuccess() {
        PersonalCenterModel.getInstance().setPhone(
                edt_bindphone.getText().toString().trim());
        bodystep3();
    }

    // VerifyCode verifyCode = null;

    void showCode(VerifyCode code) {
        TimeFactory.creator(2).Start();
        // verifyCode = code;
        ToastUtil.show(context, "验证码发送成功,请查收");
        // ToastUtil.show(context, code.getCode());
        // edt_bindphone1.setText(code.getCode());
    }

    void showUnBindCode(VerifyCode code) {
        TimeFactory.creator(3).Start();
        // verifyCode = code;
        ToastUtil.show(context, "验证码发送成功,请查收");
        edt_unbindphone.setText("");
        // ToastUtil.show(context, code.getCode());
        // edt_bindphone1.setText(code.getCode());
    }

    /**
     * 绑定手机第一步
     */
    private void bodystep1() {
        title1();
        hidestep();
        bindphone_body_setup1.setVisibility(View.VISIBLE);
        step1.setBackgroundResource(getDrawable("mch_step1_80x80_blue"));
        step1_.setTextColor(Color.parseColor("#1fcfc5"));
        lineFirst.setBackgroundColor(Color.parseColor("#1fcfc5"));
    }

    /**
     * 绑定手机第二步
     */
    private void bodystep2() {
        title2();
        hidestep();
        bindphone_body_setup2.setVisibility(View.VISIBLE);
        step_verifyidentity.setBackgroundResource(getDrawable("mch_step2_80x80_blue"));
        step_verifyidentity_.setTextColor(Color.parseColor("#1fcfc5"));
        lineSecond.setBackgroundColor(Color.parseColor("#1fcfc5"));
    }

    /**
     * 绑定手机第三步（成功界面）
     */
    private void bodystep3() {
        title3();
        hidestep();
        bindphone_body_setsuccess.setVisibility(View.VISIBLE);
    }

    /**
     * 解除绑定
     */
    private void bodystepunbind1() {
        title1();
        hidestep();
        //设置解绑界面显示
        mch_ll_unbindphone.setVisibility(View.VISIBLE);
        //设置解绑界面验证码默认隐藏
        ll_unbindphone.setVisibility(View.GONE);
    }

    /**
     * 设置所有步骤不显示
     */
    private void hidestep() {
        bindphone_body_setup1.setVisibility(View.GONE);
        bindphone_body_setup2.setVisibility(View.GONE);
        bindphone_body_setsuccess.setVisibility(View.GONE);
        mch_ll_unbindphone.setVisibility(View.GONE);
    }

    /**
     * 第一步显示
     */
    private void title1() {
        step1.setBackgroundResource(getDrawable("mch_step1_80x80_blue"));
        step_verifyidentity.setBackgroundResource(getDrawable("mch_step2_80x80_grey"));
        step_securityphone.setBackgroundResource(getDrawable("mch_step3_80x80_grey"));
        step1_.setTextColor(Color.parseColor("#1fcfc5"));
        step_verifyidentity_.setTextColor(Color.parseColor("#a0a0a0"));
        step_securityphone_.setTextColor(Color.parseColor("#a0a0a0"));
        lineFirst.setBackgroundColor(Color.parseColor("#1fcfc5"));
        lineSecond.setBackgroundColor(Color.parseColor("#a0a0a0"));
    }

    private void title2() {
        step1.setBackgroundResource(getDrawable("mch_step1_80x80_blue"));
        step_verifyidentity.setBackgroundResource(getDrawable("mch_step2_80x80_blue"));
        step_securityphone.setBackgroundResource(getDrawable("mch_step3_80x80_grey"));
        step1_.setTextColor(Color.parseColor("#1fcfc5"));
        step_verifyidentity_.setTextColor(Color.parseColor("#1fcfc5"));
        step_securityphone_.setTextColor(Color.parseColor("#a0a0a0"));
        lineFirst.setBackgroundColor(Color.parseColor("#1fcfc5"));
        lineSecond.setBackgroundColor(Color.parseColor("#1fcfc5"));
    }

    private void title3() {
        step1.setBackgroundResource(getDrawable("mch_step1_80x80_blue"));
        step_verifyidentity.setBackgroundResource(getDrawable("mch_step2_80x80_blue"));
        step_securityphone.setBackgroundResource(getDrawable("mch_step3_80x80_blue"));
        step1_.setTextColor(Color.parseColor("#1fcfc5"));
        step_verifyidentity_.setTextColor(Color.parseColor("#1fcfc5"));
        step_securityphone_.setTextColor(Color.parseColor("#1fcfc5"));
        lineFirst.setBackgroundColor(Color.parseColor("#1fcfc5"));
        lineSecond.setBackgroundColor(Color.parseColor("#1fcfc5"));
    }

    /**
     * 执行解除绑定操作
     */
    private void unbind() {
        String code = edt_unbindphone.getText().toString().trim();
        if (TextUtils.isEmpty(code)) {
            ToastUtil.show(context, "请输入短信验证码");
            return;
        }
        try {
            UserUnBindPhoneProcess process = new UserUnBindPhoneProcess();
            process.setCode(code);
            process.post(UnBindHandler);
        } catch (Exception e) {
            ToastUtil.show(context, "程序异常");
            e.printStackTrace();
        }
        return;
    }
}
